翻訳と辞書
Words near each other
・ Domiel
・ Domien Jacob
・ Domien Loubry
・ Domilise's Restaurant
・ Domin Sport
・ Domina
・ Domina (grape)
・ Domina Eberle Spencer
・ Domina Jalbert
・ Dominador Baldomero Bazán
・ Dominador Chipeco, Jr.
・ Dominador Gomez
・ Dominae
・ Dominair
・ Dominance
Dominance (C++)
・ Dominance (ecology)
・ Dominance (economics)
・ Dominance (ethology)
・ Dominance (genetics)
・ Dominance and submission
・ Dominance drawing
・ Dominance hierarchy
・ Dominance order
・ Dominance signal
・ Dominance-based rough set approach
・ Dominant (music)
・ Dominant cadence
・ Dominant Clearbody budgerigar mutation
・ Dominant culture


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Dominance (C++) : ウィキペディア英語版
Dominance (C++)

In the C++ programming language, dominance refers to a particular aspect of C++ name lookup in the presence of inheritance. When the compiler computes the set of declarations to which a particular name might refer, declarations in very-ancestral classes which are "dominated" by declarations in less-ancestral classes are ''hidden'' for the purposes of name lookup. In other languages or contexts, the same principle may be referred to as "name masking" or "shadowing".
The algorithm for computing name lookup is described in section 10.2 () of the C++11 Standard.〔(N3797 Working Draft, Standard for Programming Language C++ ). Dated 2013-10-13.〕 The Standard's description does not use the word "dominance", preferring to describe things in terms of ''declaration sets'' and ''hiding''. However, the Index contains an entry for "dominance, virtual base class" referring to section 10.2.
==Example without diamond inheritance==

void f(double, double); // at global scope
struct Grandparent ;
struct Parent : public Grandparent ;
struct Child : public Parent ;

In the above example, Child::g contains a reference to the name f. However, the program as a whole contains four declarations of the name f. In order to figure out which f is meant, the compiler computes an ''overload set'' containing all the declarations which are not hidden at the point of the call. The declaration of f at global scope is hidden by Grandparent::f, and in turn Grandparent::f is hidden by Parent::f. Thus the only declaration which is considered by overload resolution is Parent::f — and the result in this case is a diagnostic, because the call-site provides two arguments where Parent::f expects only one.
It is often surprising to new C++ programmers that the declaration of Parent::f dominates and hides ''all'' of the more-ancestral declarations, regardless of signature; that is, Parent::f(int) dominates and hides the declaration of Grandparent::f(double, double) even though the two member functions have very different signatures.
It is also important to observe that in C++, ''name lookup'' precedes ''overload resolution''. If Parent::f had multiple overloads (for example f(int) and f(double, double)), the compiler would choose between them at overload-resolution time; but during the name-lookup phase we are concerned only with choosing among the three scopes Grandparent::f, Parent::f, and ::f. The fact that Grandparent::f(double, double) would have been a better ''overload'' than f(int) is not part of the compiler's consideration.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Dominance (C++)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.